<template>
<div>
  <el-dialog title="操作离职" :visible.sync="open" width="600px" append-to-body>
    <!-- <el-alert
      title="您是否确认用户已无待办任务、无待签署任务？
    如果用户仍有未完成的任务，操作离职会导致未完成
    任务无法推进。"
      show-icon
    ></el-alert> -->

    <div class="padding">
      <div class="font margin-top-sm">离职说明</div>

      <el-input
        type="textarea"
        class="margin-top"
        :autosize="{ minRows: 4, maxRows: 6 }"
        :rows="4"
        placeholder="请输入内容"
        show-word-limit
        resize="none"
        maxlength="100"
        v-model="textarea"
      >
      </el-input>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button v-preventReClick type="primary" @click="submitForm">确 定</el-button>
      <el-button v-preventReClick @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
  <el-dialog 
    title="操作离职"
    :visible.sync="dialogVisible"
    width="36%">
    <div style="text-align: center;">
      <span > 该人员为集团管理员，请先设置其他人为该角色。</span>
    </div> 
    <span slot="footer" class="dialog-footer">
      <el-button v-preventReClick @click="dialogVisible = false">取 消</el-button>
      <el-button v-preventReClick type="primary" @click="dialogVisible = false">确 定</el-button>
    </span>
    </el-dialog> 
    </div>
</template>
<script>
import { setUserDepart,isOnlyEnterprise } from "@/api/system/user";
export default {
  data() {
    return {
      open: false,
      textarea: "",
      list: [], //离职人员
      dialogVisible:false,
    };
  },
  methods: {
    handlereg(btnselectData) {
      this.list = btnselectData;
      console.log(this.list, "this.list----");
      isOnlyEnterprise(this.list[0].id).then(response => {
        if(response.data==0){
          this.open = true;
        }else{
          this.dialogVisible = true
        }
      });
      this.textarea = "";
      
    },
    submitForm() {
      let date={
        username:this.list[0].username,
        departInfo:this.textarea,
      }
      console.log(date,'date---',this.list,this.list[0].username)
      setUserDepart(date).then(response => {
        this.$modal.msgSuccess("离职成功");
        this.$parent.getList()
        this.open = false;
      });
    },
    cancel() {
      this.open = false;
    },
  },
  created() {},
};
</script>
<style scoped lang="scss">
::v-deep .el-alert--info.is-light {
  background-color: #ffffff;
  color: #909399;
  color: #333333;
  font-weight: 400;
  .el-icon-info:before {
    color: #4a90e5;
    // background: #4A90E5
  }
}
.padding {
  padding: 0 20px;
}
.font {
  color: #333333;
  font-size: 12px;
  color: #333333;
  letter-spacing: 0;
  text-align: left;
  line-height: 18px;
  font-weight: 500;
}
</style>